package com.itranswarp.weibo.api;

/**
 * AccessToken object.
 * 
 * @author Michael Liao (askxuefeng@gmail.com)
 */
public final class AccessToken {

	public final String authorization;
	public final long expiredTime;

	public AccessToken(String authorization, long ttlInSeconds) {
		this.authorization = authorization;
		this.expiredTime = System.currentTimeMillis() + ttlInSeconds * 1000;
	}

	public void assertNotExpired() {
		if (System.currentTimeMillis() >= expiredTime)
			throw new WeiboException("Token expired");
	}
}
